package s.k.gui.webtest.log;

import java.text.DateFormat;
import java.util.Date;

import s.k.gui.webtest.log.MyLogger;

public class MyLogger {
	private String name;
	private Class<?> clazz;
	Date now = new Date();
	DateFormat df = DateFormat.getDateTimeInstance();
	String logTime = df.format(now);

	public MyLogger(String name) {

		this.name = name;
	}

	public static MyLogger getLogger(String name) {

		return new MyLogger(name);
	}

	public static MyLogger getLogger(Class<?> clazz) {

		return new MyLogger(clazz);
	}

	private MyLogger(Class<?> clazz) {

		this.clazz = clazz;
	}

	public void error(Object message) {
		
		System.out.println("#["+logTime+"]");

		System.out.print("[ERROR]+++++>");

		outputClazzInfo();

		System.out.println(message);

	}

	public void info(Object message) {
		
		System.out.print("#["+logTime+"]");

		System.out.print("[INFO]----->");

		outputClazzInfo();

		System.out.println(message);

	}

	public void warn(Object message) {
		
		System.out.print("#["+logTime+"]");

		System.out.print("[WARN]----->");

		outputClazzInfo();

		System.out.println(message);

	}

	public void outputClazzInfo() {

		if (name != null)

			System.out.print(name + ":");

		if (clazz != null)

			System.out.print(clazz.getName()+"->");

	}
}
